<!--
 * @Description:: 请补充填写
 * @Version: 1.0
 * @Author: 小白
 * @Date: 2022-04-14 14:26:46
 * @LastEditors: 小白
 * @LastEditTime: 2025-10-11 13:43:30
 * @FilePath: \tmsadmin\src\views\product_management\components\list.vue
-->

<template>
  <SearchForm @search="searchFun" style="margin-bottom: 20px" />
  <el-card class="page_card" shadow="never">
    <template #header>
      <div class="card-header">
        <div class="left">
          主营业务
          <el-button style="margin-left: 20px" type="primary" @click="add('新增')">
            新增
          </el-button>
        </div>
        <div class="right">
          <el-button circle @click="refreshFun">
            <i class="icon ion-refresh" :class="iconRefresh" />
          </el-button>
        </div>
      </div>
    </template>
    <Table :table-data="tableData" :table-columns="columns" :page-size="pageSize" :page-num="pageNum" :loading="loading"
      :total="total" @edit="edit" @selectionChange="selectionChange" @change="changePage"
      @ok="getData()" />
    <Modal @ok="getData()" ref="modalRef"></Modal>
  </el-card>
</template>
<script lang="ts" setup>
import { REQUEST } from '@/api/request'
import { ElMessage } from 'element-plus'
import SearchForm from './search.vue'
import Table from './table.vue'
import Modal from './modal.vue'
import { onMounted, ref, watch } from 'vue'
const emit = defineEmits(['go'])
const props = defineProps({
  params: {
    type: Object,
    default: () => {}
  }
})
const queryForm = ref({})
const iconRefresh = ref('')
const pageNum = ref(1)
const pageSize = ref(10)
const total = ref(0)
const modalRef = ref(null)
const loading = ref(false)
const tableData = ref([])
const columns = ref([

  {
    title: '业务名称',
    prop: 'title',
    align: 'center',
    modifiable: true,
    isShow: true,
    minwidth: '180'
  },
 
  {
    title: '业务介绍',
    prop: 'remark',
    align: 'center',
    modifiable: true,
    isShow: true,
    minwidth: '180'
  },
  {
    title: '业务详情',
    prop: 'content',
    align: 'center',
    modifiable: true,
    isShow: true,
    minwidth: '180'
  },
  {
    title: '创建时间',
    prop: 'createTime',
    align: 'center',
    modifiable: true,
    isShow: true,
    minwidth: '180'
  },
  {
    title: '操作',
    prop: 'actions',
    align: 'center',
    fixed: 'right',
    modifiable: true,
    isShow: true,
    minwidth: '300',
    tooltip: false
  }
])
onMounted(() => {
  console.log(1111)
  getData()
})
watch(props, () => {
  getData()
})
const add = (title: string) => {
  emit('go', {view: 'ActiveDetails', params: {title: title,row: null}})
}
const getData = () => {
  loading.value = true
  REQUEST.POST('NEWSLIST', {
    pageNumber: pageNum.value,
    pageSize: pageSize.value,
    type: 3,
    ...queryForm.value
  }).then((res: any) => {
    loading.value = false
    tableData.value = res.data.records
    total.value =JSON.parse(res.data.total)
  })
}
const modalRefYhq = ref()
const refreshFun = () => {
  iconRefresh.value = 'iconRefresh'
  getData()
  setTimeout(() => {
    iconRefresh.value = ''
  }, 1000)
}
const searchFun = (e: any) => {
  queryForm.value = e
  getData()
}
const selectList = ref([])
const selectionChange = (e: any) => {
  selectList.value = e.map((item: any) => item.id)
}

const edit = (row: any) => {
  emit('go', {view: 'ActiveDetails', params: { title: '编辑主营业务',row: row }})
}
const changePage = (e: any) => {
  pageNum.value = e.pageNum
  pageSize.value = e.pageSize
  getData()
}
</script>

<style lang="scss" scoped>
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
